package cn.fw.community.client.model.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import io.gitee.chearnee.fw.common.annotation.IBaseEnumJson;
import io.gitee.chearnee.fw.common.model.IBaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Getter
@AllArgsConstructor
public enum LevelEnum implements IBaseEnum<String> {
    P0("P0", "P0"),
    P1("P1", "P1"),
    P2("P2", "P2"),
    ;
    @EnumValue
    @IBaseEnumJson
    private final String value;
    private final String desc;
    private static Map<String, LevelEnum> enumMap;

    public static LevelEnum valueOfValue(String actionString) {
        if (enumMap == null) {
            enumMap = Arrays.stream(values()).collect(Collectors.toMap(LevelEnum::getValue, Function.identity()));
        }
        return enumMap.get(actionString);
    }

}
